package teste;
import br.unisul.redeNeural.Configuracao;
import br.unisul.redeNeural.ConfiguracaoCamadaIntemediaria;
import br.unisul.redeNeural.Madaline;
import br.unisul.redeNeural.ParTreino;
import br.unisul.redeNeural.RedeNeural;
import br.unisul.redeNeural.RedeNeuralException;
import br.unisul.util.Ferramentas;

public class TesteXor {


	public static void main(String[] args) {
		Configuracao configuracao = new Configuracao(2,1);
		configuracao.addCamadaIntermediaria(new ConfiguracaoCamadaIntemediaria(2));
		configuracao.setSuportaVies(true);
		configuracao.setTaxaAprendizado(.5);
		configuracao.setMultiCamadas(true);

		RedeNeural n = new Madaline(configuracao);

		ParTreino par = new ParTreino(configuracao);
		par.adicionaPar(new double[]{1,1}, new double[]{-1});
		par.adicionaPar(new double[]{1,-1}, new double[]{1});
		par.adicionaPar(new double[]{-1,1}, new double[]{1});
		par.adicionaPar(new double[]{-1,-1}, new double[]{-1});
		//		par.adicionaPar(new double[]{1,1}, new double[]{0});
		//		par.adicionaPar(new double[]{1,0}, new double[]{1});
		//		par.adicionaPar(new double[]{0,1}, new double[]{1});
		//		par.adicionaPar(new double[]{0,0}, new double[]{0});

		try {
			n.treinar(par);
		} catch (RedeNeuralException e) {
			e.printStackTrace();
		}

		try {
			System.out.println(Ferramentas.verificarSaida(n.verificarSaidas(par.getEntradas()), par.getSaidas()));
		} catch (RedeNeuralException e) {
			e.printStackTrace();
		}


	}

}
